package shixun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import shixun.dao.UserDao;
import shixun.domain.Root;
import shixun.domain.User;
import shixun.service.UserService;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao dao;


    @Override
    public User login(String username, String password) {
        User user = dao.login(username,password);
        return user;
    }

    @Override
    public Root rootLogin(String username, String password) {
        Root root = dao.rootLogin(username,password);
        return root;
    }

    @Override
    public void add(User user) {
        dao.add(user);
    }

    @Override
    public void update(String username, String password) {
        dao.update(username,password);
    }

    @Override
    public int findIdByUsername(String username) {
        int id = dao.findIdByUsername(username);
        return id;
    }

    @Override
    public boolean findUser(String username) {
        User user = dao.findUser(username);
        if (user!=null){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public List<User> findAllUsers() {
        List<User> users = dao.findAllUsers();
        return users;
    }

    @Override
    public void frozen(int id) {
        String N = "N";
        dao.frozen(id,N);
    }

    @Override
    public void thaw(int id) {
        String Y = "Y";
        dao.thaw(id,Y);
    }

    @Override
    public void cancellation(int id) {
        dao.cancellation(id);
    }
}
